<template>
    <div class="slide">

        <!--S列表滑动-->
        <cube-slide
                id="slide"
                ref="slide"
                :data="data"
                :loop="false"
                :showDots="false"
                :autoPlay="false"
                direction="vertical"
                :threshold="0.4"
                :refreshResetCurrent="false"
                @change="change">

                    <cube-slide-item v-for="item in data" :key="item.id">
                        <!--S默认红包-->
                        <normal
                                v-if="item.red_type === 'normal'"
                                :red-id="item.id"
                        >
                        </normal>
                        <!--E默认红包-->

                        <!--S图片红包-->
                        <pic
                                v-else-if="item.red_type === 'pic'"
                                :red-id="item.id"
                                :change-red-id="change_red_id"
                        >
                        </pic>
                        <!--S图片红包-->

                        <!--S视频红包-->
                        <ivideo v-else
                                :red-id="item.id"
                                :change-red-id="change_red_id"
                        ></ivideo>
                        <!--E视频红包-->
                    </cube-slide-item>

        </cube-slide>
        <!--E列表滑动-->

    </div>
</template>

<script>
    import normal from "../../module/slide/components/normal/Normal";
    import pic from "../../module/slide/components/pic/Pic";
    import ivideo from "../../module/slide/components/ivideo/IVideo";
    import share from "../../util/share";
    export default {
        name: "slide",
        data(){
          return {
              change_red_id:""  //切换时的红包id
          }
        },
        props:{
            data:{
                type:Array,
                default(){
                    return []
                }
            },
        },
        components:{
            normal,
            pic,
            ivideo
        },
        methods:{
            //组件切换
            change(index){
                //bind-events
                this.$emit("change",index);
                this.change_red_id = this.data[index].id;
                if(this.$wx) share(this.$route.name,this.change_red_id);
            }
        }
    }
</script>

<style scoped lang="less" src="./slide.less"></style>